home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / Installer SDK Cornucopia 1.0.2 / Script Examples / Rsrc Compression⁄Split Example / rsrcCompress.r < prev    next >
Encoding:
Text File  |  1996-09-30  |  16.4 KB  |  480 lines  |  [TEXT/MPS ]

  1. //
  2. //    rsrcCompress.r
  3. //
  4. //        This installer script source demonstrates use of InstaCompOne 
  5. //        resource archives, split resources, the InstaCompOneTool 
  6. //        compression utility, and the FileAndRsrcSplitterTool.
  7. //
  8. //    How To Build the Script:
  9. //    
  10. //        To build installer script access "Build…" item within "Build" menu
  11. //        and enter the scriptName "rsrcCompress". To build the installer
  12. //        debugger version of the installer script enter the scriptname
  13. //        with the addition ".debug" ( "rsrcCompress.debug" ).
  14. //
  15. //        There must be a copy of the file "InstaCompOneSCExt.rsrc"
  16. //        that has been renamed to "rsrcCompress.scx" included in this
  17. //        folder as well. This file will automatically be copied and
  18. //        renamed ( from the InstaCompOne folder in the SDK ) when the
  19. //        makefile for this example is run.
  20. //
  21. //    What this example does :
  22. //
  23. //        Four Custom Install options are provided to the user:
  24. //
  25. //        1) Installs a Example File onto the selected target 
  26. //        volume ( without use of compression or file splitting ). This
  27. //        installed file is included only as the target of the other three
  28. //        Custom Install options. 
  29. //
  30. //        NOTE: Resource installation can be specified as either requiring
  31. //        an existing target file, or not requiring an existing target file.
  32. //        All resource installation options in this example have been set
  33. //        so that a target is required. If you try the resource installation
  34. //        options ( 2), 3), 4) ) without first installing the first option, 
  35. //        an error dialog will be provided and installation will be prevented
  36. //        from continuing.
  37. //
  38. //        2) Install resource item of type 'STR#' and ID 9000. Adds the 
  39. //        'STR#' resource item to the Example File file installed in option 1).
  40. //        This option demonstrates resource compression.
  41. //
  42. //        3) Install resource item of type 'STR#' and ID 9100. Adds the 
  43. //        'STR#' resource item to the Example File file installed in option 1).
  44. //        This option demonstrates resource splitting and compression.
  45. //
  46. //        4) Install resource item of type 'STR#' and ID 9200. Adds the 
  47. //        'STR#' resource item to the Example File file installed in option 1).
  48. //        This option demonstrates resource splitting.
  49. //
  50. //
  51. //        All target files from example installations are placed in a 
  52. //        folder called ":InstaComp Rsrc Testing:" on the root folder of 
  53. //        the target volume of installation.
  54. //
  55. //    NOTE: InstaCompOne can be used to split and compress files and 
  56. //    fonts in addition to resources, but this example deals only with 
  57. //    splitting and compressing resources. (For examples of file and font
  58. //    compression and splitting see:  "File Compression/Split Example",
  59. //    "Font Compression/Split Example", and "InstaCompOneExample".)
  60. //
  61. //  NOTE: It's best to store the split or compressed resource as type
  62. //    'part', instead of the original type, to prevent errors due to
  63. //    the assumption that if it's of a certain type it must be complete.
  64. //
  65. //     NOTE: When using InstaCompOne compression and splitting, simply enter 241
  66. //     as the value for the atom extender ( 'inex' ) in the next to last field
  67. //     of the atom ( 'infa', 'inff', 'inra' ) for the file/font/rsrc to be
  68. //     decompressed. There is no need to declare an 'inex' resource within the
  69. //     installer script source. An 'inex' resource definition is contained in
  70. //     the InstaCompOne resource file that is included at the top of this file.
  71. //
  72. //    NOTE: When splitting files or resources without using compression
  73. //    pass a value of 0 ( zero ) for the atom extender in the atom extender
  74. //    field of the atom ( 'infa', 'inra', 'inff' ).
  75. //
  76. //        Copyright 1993-1996, Apple Computer, Inc., All Rights Reserved
  77. //
  78.  
  79. #include "InstallerTypes.r"
  80.  
  81. // Include the InstaCompOne atom extender stuff
  82. // making sure not to add their version resource
  83. // to our installer script. Also, since this include
  84. // is a resource include instead of a #include, it is
  85. // not actually a pre-processor thing, and won't be effected
  86. // by a -i option within the rez line in the makefile. 
  87. include ":::Tools:Released:InstaCompOne 1.1:InstaCompAtomExt.rsrc" NOT 'vers';
  88.  
  89.  
  90. // • packages
  91.  
  92. // package that installs Example File - no compression or splitting used
  93. // this file is intended only as the target for the following packages
  94. // that will install resource items into the Example File
  95. resource 'inpk' (100) {
  96.     format0 {
  97.         showsOnCustom,
  98.         notRemovable,
  99.         dontForceRestart,
  100.         0,
  101.         0,
  102.         "Install Example File [ DO THIS FIRST !! SO RSRC'S CAN BE ADDED TO IT ]",
  103.         {    
  104.         'infa', 1000;
  105.         },
  106.     }
  107. };
  108.  
  109. // package that demonstrates decompressing one resource item 
  110. // and adding the result to one target file
  111. resource 'inpk' (200) {
  112.     format0 {
  113.         showsOnCustom,
  114.         removable,
  115.         dontForceRestart,
  116.         0,
  117.         0,
  118.         "Add rsrc item 'STR#' (9000) to Example File [ compress rsrc example ]",
  119.         {    
  120.         'inra', 2000;
  121.         },
  122.     }
  123. };
  124.  
  125. // package that demonstrates decompressing two resource item pieces 
  126. // and adding the result to one target file
  127. resource 'inpk' (300) {
  128.     format0 {
  129.         showsOnCustom,
  130.         removable,
  131.         dontForceRestart,
  132.         0,
  133.         0,
  134.         "Add rsrc item 'STR#' (9100) to Example File [ split,compress rsrc example ]",
  135.         {    
  136.         'inra', 3000;
  137.         },
  138.     }
  139. };
  140.  
  141. // package that demonstrates joining two resource item pieces 
  142. // and adding the result to one target file
  143. resource 'inpk' (400) {
  144.     format0 {
  145.         showsOnCustom,
  146.         removable,
  147.         dontForceRestart,
  148.         0,
  149.         0,
  150.         "Add rsrc item 'STR#' (9200) to Example File [ split rsrc example ]",
  151.         {    
  152.         'inra', 4000;
  153.         },
  154.     }
  155. };
  156.  
  157.  
  158. // • file atoms
  159.  
  160. // simple installation of Example File ( no compression, no splitting )
  161. resource 'infa' (1000) {
  162.     format1 {
  163.         deleteWhenRemoving,                //  Delete on deinstall
  164.         deleteWhenInstalling,            //  Remove preexisting
  165.         copy,                            //  Copy on Install
  166.         dontIgnoreLockedFile,            //  Respect file locking
  167.         dontSetFileLocked,                //  Leave installed file unlocked
  168.         useSrcCrDateToCompare,            //  Use creation date for compare
  169.         srcNeedNotExist,                //  Create a new file if necessary
  170.         rsrcForkInRsrcFork,                //  Resource stuff in Resource fork
  171.         leaveAloneIfNewer,                //  Do not update a newer file
  172.         updateExisting,                    //  Update an existing file
  173.         copyIfNewOrUpdate,                //  Copy whether target exists or not
  174.         rsrcFork,                        //  Copy resource fork
  175.         dataFork,                        //  Copy data fork
  176.         
  177.         0,                    // TARGET - size ( filled in by ScriptCheck )
  178.         0x0,                // finder attribute flags ( filled in by ScriptCheck )
  179.         10000,                // TARGET - file spec ( 'infs' )
  180.         {    
  181.             11000,            // SOURCE - file spec ( 'infs' )
  182.             0,                 // DATA fork - size ( filled in by ScriptCheck )
  183.             0                // RSRC fork - size ( filled in by ScriptCheck )
  184.         },    
  185.         
  186.         0x0,                // SOURCE - version number for comparisons
  187.                             // value of 0x0 specifies not to perform version comparison
  188.                             
  189.         0,                    // 'invc' code resource - version comparison routine 
  190.                             // ( none used here )
  191.         
  192.         0,                    // 'inex' resource definition for atom extender
  193.                             // • #241 is for built in InstaCompOne extender
  194.                             // NO COMPRESSION USED IN THIS EXAMPLE
  195.                             
  196.         "Example File"            // file atom description
  197.     }
  198. };
  199.  
  200.  
  201. // • resource atoms
  202.  
  203. // installation of a compressed resource item to target file
  204. resource 'inra' (2000) {
  205.     format1 {
  206.         deleteWhenRemoving,                //  Delete on deinstall
  207.         deleteWhenInstalling,            //  Remove preexisting
  208.         copy,                            //  Copy on Install
  209.         leaveAloneIfNewer,                //  Do not update a newer file
  210.  
  211.         tgtRequired,                    //  Target file must already exist
  212.                                         //  • NOTE - this is the option
  213.                                         //  that prevents installation if
  214.                                         //  the target file to add the rsrc
  215.                                         //     item to does not already exist.
  216.                                         //    To create a new "empty" file
  217.                                         //    before adding the rsrc item
  218.                                         //  change the flag to 'noTgtRequired'
  219.                                         
  220.         updateExisting,                    //  Update an existing file
  221.         copyIfNewOrUpdate,                //  Copy whether target exists or not
  222.         dontIgnoreProtection,            //  Respect file locking
  223.         srcNeedExist,                    //  Source file must exist
  224.         byID,                            //  Use rsrc ID instead of name
  225.         nameNeedNotMatch,                //  Ignored when using 'byID'
  226.         
  227.         0,                    // TARGET - total resource size after installation
  228.         10000,                // TARGET - file spec ( 'intf' )
  229.         'STR#',                // TARGET - resource type 
  230.         9000,                // TARGET - resource ID
  231.         0x0,                // TARGET - resource attribute flags ( filled in by ScriptCheck )
  232.         "",                    // TARGET - resource name 
  233.         {    
  234.             12000,            // SOURCE - file spec ( 'infs' )
  235.             'part',            // SOURCE - resource type
  236.             9000,            // SOURCE - resource ID
  237.             0,                // TARGET - resource size ( filled in by ScriptCheck )
  238.             "",                // SOURCE - resource name
  239.         },    
  240.         
  241.         0x0,                // SOURCE - version number for comparisons
  242.                             // value of 0x0 specifies not to perform version comparison
  243.                             
  244.         0,                    // 'invc' code resource - version comparison routine 
  245.                             // ( none used here )
  246.         
  247.         241,                // 'inex' resource definition for atom extender
  248.                             // • 241 is for built in InstaCompOne extender
  249.  
  250.         "",                    // resource atom description                    
  251.     }
  252. };
  253.  
  254.  
  255. // installation of a split and compressed resource item to target file
  256. resource 'inra' (3000) {
  257.     format1 {
  258.         deleteWhenRemoving,                //  Delete on deinstall
  259.         deleteWhenInstalling,            //  Remove preexisting
  260.         copy,                            //  Copy on Install
  261.         leaveAloneIfNewer,                //  Do not update a newer file
  262.  
  263.         tgtRequired,                    //  Target file must already exist
  264.                                         //  • NOTE - this is the option
  265.                                         //  that prevents installation if
  266.                                         //  the target file to add the rsrc
  267.                                         //     item to does not already exist.
  268.                                         //    To create a new "empty" file
  269.                                         //    before adding the rsrc item
  270.                                         //  change the flag to 'noTgtRequired'
  271.                                         
  272.         updateExisting,                    //  Update an existing file
  273.         copyIfNewOrUpdate,                //  Copy whether target exists or not
  274.         dontIgnoreProtection,            //  Respect file locking
  275.         srcNeedExist,                    //  Source file must exist
  276.         byID,                            //  Use rsrc ID instead of name
  277.         nameNeedNotMatch,                //  Ignored when using 'byID'
  278.         
  279.         0,                    // TARGET - total resource size after installation
  280.         10000,                // TARGET - file spec ( 'infs' )
  281.         'STR#',                // TARGET - resource type 
  282.         9100,                // TARGET - resource ID
  283.         0x0,                // TARGET - resource attribute flags ( filled in by ScriptCheck )
  284.         "",                    // TARGET - resource name 
  285.         {    
  286.             13000,            // SOURCE - file spec ( 'infs' )
  287.             'part',            // SOURCE - resource type
  288.             9100,            // SOURCE - resource ID
  289.             0,                // TARGET - resource size ( filled in by ScriptCheck )
  290.             "",                // SOURCE - resource name
  291.  
  292.             13001,            // SOURCE - file spec ( 'infs' )
  293.             'part',            // SOURCE - resource type
  294.             9101,            // SOURCE - resource ID
  295.             0,                // TARGET - resource size ( filled in by ScriptCheck )
  296.             "",                // SOURCE - resource name
  297.         },    
  298.         
  299.         0x0,                // SOURCE - version number for comparisons
  300.                             // value of 0x0 specifies not to perform version comparison
  301.                             
  302.         0,                    // 'invc' code resource - version comparison routine 
  303.                             // ( none used here )
  304.         
  305.         241,                // 'inex' resource definition for atom extender
  306.                             // • #241 is for built in InstaCompOne extender
  307.                             
  308.         "",                    // resource atom description                    
  309.     }
  310. };
  311.  
  312.  
  313. // installation of a split resource to target file
  314. // • InstaCompOne atom extender not need for non-compressed items
  315. resource 'inra' (4000) {
  316.     format1 {
  317.         deleteWhenRemoving,                //  Delete on deinstall
  318.         deleteWhenInstalling,            //  Remove preexisting
  319.         copy,                            //  Copy on Install
  320.         leaveAloneIfNewer,                //  Do not update a newer file
  321.  
  322.         tgtRequired,                    //  Target file must already exist
  323.                                         //  • NOTE - this is the option
  324.                                         //  that prevents installation if
  325.                                         //  the target file to add the rsrc
  326.                                         //     item to does not already exist.
  327.                                         //    To create a new "empty" file
  328.                                         //    before adding the rsrc item
  329.                                         //  change the flag to 'noTgtRequired'
  330.                                         
  331.         updateExisting,                    //  Update an existing file
  332.         copyIfNewOrUpdate,                //  Copy whether target exists or not
  333.         dontIgnoreProtection,            //  Respect file locking
  334.         srcNeedExist,                    //  Source file must exist
  335.         byID,                            //  Use rsrc ID instead of name
  336.         nameNeedNotMatch,                //  Ignored when using 'byID'
  337.         
  338.         0,                    // TARGET - total resource size after installation
  339.         10000,                // TARGET - file spec ( 'infs' )
  340.         'STR#',                // TARGET - resource type 
  341.         9200,                // TARGET - resource ID
  342.         0x0,                // TARGET - resource attribute flags ( filled in by ScriptCheck )
  343.         "",                    // TARGET - resource name 
  344.         {    
  345.             14000,            // SOURCE - file spec ( 'infs' )
  346.             'part',            // SOURCE - resource type
  347.             9200,            // SOURCE - resource ID
  348.             0,                // TARGET - resource size ( filled in by ScriptCheck )
  349.             "",                // SOURCE - resource name
  350.  
  351.             14001,            // SOURCE - file spec ( 'infs' )
  352.             'part',            // SOURCE - resource type
  353.             9201,            // SOURCE - resource ID
  354.             0,                // TARGET - resource size ( filled in by ScriptCheck )
  355.             "",                // SOURCE - resource name
  356.         },    
  357.         
  358.         0x0,                // SOURCE - version number for comparisons
  359.                             // value of 0x0 specifies not to perform version comparison
  360.                             
  361.         0,                    // 'invc' code resource - version comparison routine 
  362.                             // ( none used here )
  363.         
  364.         0,                    // Atom Extender not needed for joining ( w/o compression )    
  365.         
  366.         "",                    // resource atom description                    
  367.     }
  368. };
  369.  
  370.  
  371.  
  372. // • file specs
  373.  
  374. // target file spec for "Example File"
  375. // NOTE: When a target spec is called from within a resource atom of
  376. // any kind ( 'inra', 'inrm', 'inr#' ), the type, creator, dates and
  377. // Finder attributes fields will only apply when creating a new file.
  378. resource 'intf' (10000) {
  379.     format1 {
  380.         noSearchForFile,                 // use default search path
  381.         
  382.         TypeCrNeedNotMatch,             // If this is set to TypeCrMustMatch
  383.                                         // then a file with a different type
  384.                                         // and creator than those specified
  385.                                         // below will not be updated.
  386.                                         // If this is set to TypeCrNeedNotMatch
  387.                                         // then type and creator of an existing
  388.                                         // target file are ignored.
  389.         
  390.         // The Type and Creator fields will be used to set the
  391.         // file's Type and Creator when a new file is created. 
  392.         'ttro',                         // TYPE for new file
  393.         'ttxt',                         // CREATOR for new file
  394.         
  395.         0,                                 // finder attribute flags
  396.                                         // filled by ScriptCheck is value is 0
  397.         
  398.         1,                                  // creation date for new file
  399.         1,                                  // modification date for new file
  400.                                         // NOTE: DATE values are filled
  401.                                         // by ScriptCheck if the value is 1
  402.                                             
  403.         0,                                 // search proc ID ( 'insp' ), none used
  404.         
  405.         ":InstaComp Rsrc Testing:Example File"    // path to target file
  406.         }
  407.     };
  408.  
  409. // source file spec for "Example File"
  410. // • no compression
  411. resource 'infs' (11000) {
  412.     'ttro',                        // TYPE for file search
  413.     'ttxt',                        // CREATOR for file search
  414.     0x0,                        // creation DATE for source file
  415.     noSearchForFile,            // IGNORED in Installer 4.0.x
  416.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  417.     "Disk 1:Example File"            // PATH to source file        
  418. };
  419.  
  420. // • compressed resource - file specs
  421.  
  422. // source file spec for archive • compressed resource
  423. resource 'infs' (12000) {
  424.     'ircp',                        // TYPE 
  425.     'kakc',                        // CREATOR 
  426.     0x0,                        // creation DATE for source file
  427.     noSearchForFile,            // IGNORED in Installer 4.0.x
  428.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  429.     "Disk 1:CompressedRsrcTome"        // PATH to source file        
  430. };
  431.  
  432. // • split and compressed resource - file specs
  433.  
  434. // source file spec for archive containing first piece 
  435. // • split resource fork with compression
  436. resource 'infs' (13000) {
  437.     'ircp',                        // TYPE 
  438.     'kakc',                        // CREATOR 
  439.     0x0,                        // creation DATE for source file
  440.     noSearchForFile,            // IGNORED in Installer 4.0.x
  441.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  442.     "Disk 1:SplitCompRsrcTome1"            // PATH to source file        
  443. };
  444.  
  445. // source file spec for archive containing second piece 
  446. // • split resource with compression
  447. resource 'infs' (13001) {
  448.     'ircp',                        // TYPE 
  449.     'kakc',                        // CREATOR 
  450.     0x0,                        // creation DATE for source file
  451.     noSearchForFile,            // IGNORED in Installer 4.0.x
  452.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  453.     "Disk 2:SplitCompRsrcTome2"            // PATH to source file        
  454. };
  455.  
  456. // • split resource - file specs
  457.  
  458. // source file spec for archive containing first piece 
  459. // • split resource
  460. resource 'infs' (14000) {
  461.     'rsrc',                        // TYPE 
  462.     'RSED',                        // CREATOR 
  463.     0x0,                        // creation DATE for source file
  464.     noSearchForFile,            // IGNORED in Installer 4.0.x
  465.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  466.     "Disk 1:SplitRsrcTome1"            // PATH to source file        
  467. };
  468.  
  469. // source file spec for archive containing second piece 
  470. // • split resource
  471. resource 'infs' (14001) {
  472.     'rsrc',                        // TYPE 
  473.     'RSED',                        // CREATOR 
  474.     0x0,                        // creation DATE for source file
  475.     noSearchForFile,            // IGNORED in Installer 4.0.x
  476.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  477.     "Disk 2:SplitRsrcTome2"            // PATH to source file        
  478. };
  479.  
  480.